home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / plaf / basic / BasicDesktopPaneUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  3.7 KB  |  115 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Graphics;
  5. import javax.swing.DefaultDesktopManager;
  6. import javax.swing.DesktopManager;
  7. import javax.swing.JComponent;
  8. import javax.swing.JDesktopPane;
  9. import javax.swing.KeyStroke;
  10. import javax.swing.UIManager;
  11. import javax.swing.plaf.ComponentUI;
  12. import javax.swing.plaf.DesktopPaneUI;
  13. import javax.swing.plaf.UIResource;
  14.  
  15. public class BasicDesktopPaneUI extends DesktopPaneUI {
  16.    private static Dimension minSize = new Dimension(0, 0);
  17.    private static Dimension maxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  18.    protected JDesktopPane desktop;
  19.    protected DesktopManager desktopManager;
  20.    protected KeyStroke minimizeKey;
  21.    protected KeyStroke maximizeKey;
  22.    protected KeyStroke closeKey;
  23.    protected KeyStroke navigateKey;
  24.    protected KeyStroke navigateKey2;
  25.  
  26.    public static ComponentUI createUI(JComponent var0) {
  27.       return new BasicDesktopPaneUI();
  28.    }
  29.  
  30.    public Dimension getMaximumSize(JComponent var1) {
  31.       return maxSize;
  32.    }
  33.  
  34.    public Dimension getMinimumSize(JComponent var1) {
  35.       return minSize;
  36.    }
  37.  
  38.    public Dimension getPreferredSize(JComponent var1) {
  39.       return null;
  40.    }
  41.  
  42.    protected void installDefaults() {
  43.       if (this.desktop.getBackground() == null || this.desktop.getBackground() instanceof UIResource) {
  44.          this.desktop.setBackground(UIManager.getColor("Desktop.background"));
  45.       }
  46.  
  47.    }
  48.  
  49.    protected void installDesktopManager() {
  50.       if (this.desktop.getDesktopManager() == null) {
  51.          this.desktopManager = new DefaultDesktopManager();
  52.          this.desktop.setDesktopManager(this.desktopManager);
  53.       }
  54.  
  55.    }
  56.  
  57.    protected void installKeyboardActions() {
  58.       this.minimizeKey = KeyStroke.getKeyStroke(120, 2);
  59.       this.maximizeKey = KeyStroke.getKeyStroke(121, 2);
  60.       this.closeKey = KeyStroke.getKeyStroke(115, 2);
  61.       this.navigateKey = KeyStroke.getKeyStroke(117, 2);
  62.       this.navigateKey2 = KeyStroke.getKeyStroke(9, 2);
  63.       this.registerKeyboardActions();
  64.    }
  65.  
  66.    public void installUI(JComponent var1) {
  67.       this.desktop = (JDesktopPane)var1;
  68.       this.installDefaults();
  69.       this.installDesktopManager();
  70.       this.installKeyboardActions();
  71.    }
  72.  
  73.    public void paint(Graphics var1, JComponent var2) {
  74.    }
  75.  
  76.    protected void registerKeyboardActions() {
  77.       this.desktop.registerKeyboardAction(new MinimizeAction(this), this.minimizeKey, 2);
  78.       this.desktop.registerKeyboardAction(new MaximizeAction(this), this.maximizeKey, 2);
  79.       this.desktop.registerKeyboardAction(new CloseAction(this), this.closeKey, 2);
  80.       this.desktop.registerKeyboardAction(new NavigateAction(this), this.navigateKey2, 2);
  81.       this.desktop.registerKeyboardAction(new NavigateAction(this), this.navigateKey, 2);
  82.    }
  83.  
  84.    protected void uninstallDefaults() {
  85.    }
  86.  
  87.    protected void uninstallDesktopManager() {
  88.       if (this.desktop.getDesktopManager() == this.desktopManager) {
  89.          this.desktop.setDesktopManager((DesktopManager)null);
  90.       }
  91.  
  92.       this.desktopManager = null;
  93.    }
  94.  
  95.    protected void uninstallKeyboardActions() {
  96.       this.unregisterKeyboardActions();
  97.    }
  98.  
  99.    public void uninstallUI(JComponent var1) {
  100.       this.uninstallKeyboardActions();
  101.       this.uninstallDesktopManager();
  102.       this.uninstallDefaults();
  103.       this.desktop = null;
  104.    }
  105.  
  106.    protected void unregisterKeyboardActions() {
  107.       this.desktop.unregisterKeyboardAction(this.minimizeKey);
  108.       this.desktop.unregisterKeyboardAction(this.maximizeKey);
  109.       this.desktop.unregisterKeyboardAction(this.closeKey);
  110.       this.desktop.unregisterKeyboardAction(this.navigateKey);
  111.       this.desktop.unregisterKeyboardAction(this.navigateKey2);
  112.       this.minimizeKey = this.maximizeKey = this.closeKey = this.navigateKey = this.navigateKey2 = null;
  113.    }
  114. }
  115.